move error handling out of line to avoid duplicated code.
authorvhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Sat, 31 Dec 2005 14:16:13 +0000 (14:16 +0000)
committervhanquez@kneesa.uk.xensource.com <vhanquez@kneesa.uk.xensource.com>
Sat, 31 Dec 2005 14:16:13 +0000 (14:16 +0000)
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
linux-2.6-xen-sparse/drivers/xen/netback/interface.c

index 16cc929a111df40b21768dfe4f43efefd2ff371a..a27533cf87b1bc9070399892e4c70de1d43f1cf0 100644 (file)
@@ -183,7 +183,7 @@ static void unmap_frontend_pages(netif_t *netif)
 int netif_map(netif_t *netif, unsigned long tx_ring_ref,
              unsigned long rx_ring_ref, unsigned int evtchn)
 {
-       int err;
+       int err = -ENOMEM;
        netif_tx_sring_t *txs;
        netif_rx_sring_t *rxs;
        evtchn_op_t op = {
@@ -199,25 +199,16 @@ int netif_map(netif_t *netif, unsigned long tx_ring_ref,
        if (netif->tx_comms_area == NULL)
                return -ENOMEM;
        netif->rx_comms_area = alloc_vm_area(PAGE_SIZE);
-       if (netif->rx_comms_area == NULL) {
-               free_vm_area(netif->tx_comms_area);
-               return -ENOMEM;
-       }
+       if (netif->rx_comms_area == NULL)
+               goto err_rx;
 
        err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref);
-       if (err) {
-               free_vm_area(netif->tx_comms_area);
-               free_vm_area(netif->rx_comms_area);
-               return err;
-       }
+       if (err)
+               goto err_map;
 
        err = HYPERVISOR_event_channel_op(&op);
-       if (err) {
-               unmap_frontend_pages(netif);
-               free_vm_area(netif->tx_comms_area);
-               free_vm_area(netif->rx_comms_area);
-               return err;
-       }
+       if (err)
+               goto err_hypervisor;
 
        netif->evtchn = op.u.bind_interdomain.local_port;
 
@@ -245,6 +236,13 @@ int netif_map(netif_t *netif, unsigned long tx_ring_ref,
        rtnl_unlock();
 
        return 0;
+err_hypervisor:
+       unmap_frontend_pages(netif);
+err_map:
+       free_vm_area(netif->rx_comms_area);
+err_rx:
+       free_vm_area(netif->tx_comms_area);
+       return err;
 }
 
 static void free_netif_callback(void *arg)